package com.hdd.art.biz.painting.controller;


import com.hdd.art.biz.member.dto.MemberDo;
import com.hdd.art.biz.painting.dto.*;
import com.hdd.art.biz.painting.entity.WorkVerify;
import com.hdd.art.biz.painting.service.WorkVerifyService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-07-10
 */
@RestController
@RequestMapping("/verify")
@Api(value = "作品模块-审核",tags = {"作品模块-审核"})
public class WorkVerifyController {

    @Autowired
    private WorkVerifyService workVerifyService;

    @PostMapping("/getVerifyByWoriId")
    @ApiOperation(value = "投稿记录" ,notes = "")
    public AppResponse getVerifyByWoriId(@Valid @RequestBody VerifyListDto dto ){
        AppResponse response = new AppResponse();
        response.setItems(workVerifyService.getVerifyByWoriId(dto.getWorkId()));
        return response;
    }


    @PostMapping("/contribute")
    @ApiOperation(value = "投稿" ,notes = "")
    public AppResponse contribute(@Valid @RequestBody ContributeDto dto ){
        AppResponse response = new AppResponse();
        workVerifyService.contribute(dto.getWorkId(),dto.getArtId(),dto.getRoomId(),dto.getUserId());
        return response;
    }

    @PostMapping("/updateStauts")
    @ApiOperation(value = "修改投稿状态" ,notes = "")
    public AppResponse updateStauts(@Valid @RequestBody UpdateStautsDto stautsDto ){
        AppResponse response = new AppResponse();
        workVerifyService.updateStauts(stautsDto.getVid(),stautsDto.getWorkId(),stautsDto.getStatus(),stautsDto.getReason());
        return response;
    }

    @PostMapping("/join")
    @ApiOperation(value = "加入作品库" ,notes = "")
    public AppResponse join(@Valid @RequestBody UpdateStautsDto stautsDto ){
        AppResponse response = new AppResponse();
        workVerifyService.updateStauts(stautsDto.getVid(),stautsDto.getWorkId(),1,stautsDto.getReason());
        return response;
    }

    @PostMapping("/adopt")
    @ApiOperation(value = "通过" ,notes = "")
    public AppResponse adopt(@Valid @RequestBody UpdateStautsDto stautsDto ){
        AppResponse response = new AppResponse();
        workVerifyService.updateStauts(stautsDto.getVid(),stautsDto.getWorkId(),1,stautsDto.getReason());
        return response;
    }

    @PostMapping("/reject")
    @ApiOperation(value = "不通过" ,notes = "")
    public AppResponse reject(@Valid @RequestBody UpdateStautsDto stautsDto ){
        AppResponse response = new AppResponse();
        workVerifyService.updateStauts(stautsDto.getVid(),stautsDto.getWorkId(),-1,stautsDto.getReason());
        return response;
    }

    @PostMapping("/publishNow")
    @ApiOperation(value = "立即发布" ,notes = "")
    public AppResponse publishNow(@Valid @RequestBody UpdateStautsDto stautsDto ){
        AppResponse response = new AppResponse();
        workVerifyService.updateStauts(stautsDto.getVid(),stautsDto.getWorkId(),2,stautsDto.getReason());
        return response;
    }
}

